#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>


#define LOGGING_ERROR
#include "logger.h"


#define LOG_THREADS 16

pthread_t log_threads[LOG_THREADS];

void* log_routine(void* args)
{
	int i = 1000;
	while(i--) {
		usleep(rand() % 1000);
		LOG_ERROR("A : %d", rand());
		LOG_WARNING("B : %d", rand());
		LOG_INFO("A : %d", rand());
		LOG_FATAL("B : %d", rand());
	}
	LOGGER_EXIT();
}

int main()
{
	LOGGER_INIT("foobar");
	int i;
	for(i = 0; i < LOG_THREADS; i++)
		if(pthread_create(&log_threads[i], NULL, log_routine, NULL) < 0)
			printf("PANIC\n");
			
	LOG_INFO("A : %d", rand());
	LOG_FATAL("B : %d", rand());

	LOGGER_WAIT();
	return 0;
}
